package cn.fl.inscare.controller;

import cmm.comm.facade.framework.api.ISysRegionApiService;
import cmm.comm.facade.framework.condition.SysRegionQueryCondition;
import cmm.comm.facade.framework.dto.SysRegionDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DecimalUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.inscare.service.IInsApplicationStagingService;
import cn.fl.inscare.vo.AddAplicationVo;
import cn.fl.inscare.vo.InsApplicationVO;
import cn.fl.inscare.vo.InsQuoteInfoVO;
import cn.fl.inscare.vo.QuotationVO;
import cn.fl.insurance.condition.InsCompInfoQueryCondition;
import cn.fl.insurance.dto.InsCompInfoDTO;
import cn.fl.insurance.service.IInsCompInfoApiService;
import cn.fl.system.constant.SysLogConstant;


import cn.fl.upload.constant.UploadConstant;
import ins.car.facade.car.car.condition.InsCompInfoQC;
import net.sf.json.JSONArray;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;









import com.alibaba.fastjson.JSONObject;

import ins.car.facade.car.car.common.MoneyConvert;
import ins.car.facade.car.car.dto.InsApplicationDTO;
import ins.car.facade.car.car.dto.InsPolicyDetailDTO;
import ins.car.facade.car.prj.dto.InsPrjApplRDTO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 申請分期
 * Created by qxl on
 * 2018/9/11
 */
@Controller
@RequestMapping("/inscare/insapplication")
public class InsApplicationStagingController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(InsApplicationStagingController.class);

    @Autowired
    private IInsApplicationStagingService insApplicationStagingService;
    @Autowired
    private ISysRegionApiService sysRegionApiService;
    @Autowired
    private IInsCompInfoApiService insCompInfoApiService;
    /**
     * 跳转到查看分期申请
     */
    @RequestMapping(value = "/toInsApplicationStagingPage.do", method = { RequestMethod.GET,RequestMethod.POST})
    public ModelAndView toInsApplicationStagingPage(HttpServletRequest request, HttpServletResponse response){
        //获取参数
        String prjId = request.getParameter("prjId");
        String paySchNo = request.getParameter("paySchNo");
        ModelAndView view = new ModelAndView("inscare/stages/insApplicationStaging");
        if (StringUtils.isNotEmpty(prjId)){
            view.addObject("prjId",prjId);
        }
        if (StringUtils.isNotEmpty(paySchNo)){
            view.addObject("paySchNo",paySchNo);
        }
        BaseLogUtils.info(logger, "toInsApplicationStagingPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 初始化列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initInsList.do", method = { RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    public Object initInsList(HttpServletRequest request, HttpServletResponse response) {
        String prjId = request.getParameter("prjId");//项目id
        String paySchNo = request.getParameter("paySchNo");//支付表id

        List<InsApplicationVO> list ;
        list = this.insApplicationStagingService.getInsQuoteInfoList(Long.valueOf(prjId),paySchNo);
        ListPageVO<InsApplicationVO> listPage = new ListPageVO<InsApplicationVO>(list, list.size());
        BaseLogUtils.info(logger, "initInsList", "查询数据完成. DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
        return listPage;
    }


    //toAgentDetail
    /**
     * 通过申请表id查看
     */
    @RequestMapping(value = "/toAgentDetail.do", method = { RequestMethod.GET})
    public ModelAndView toAgentDetail(HttpServletRequest request, HttpServletResponse response){
        //获取参数
        String insPerNm = request.getParameter("insPerNm");
        String applicationId = request.getParameter("applicationId");
        ModelAndView view = null;
        if (StringUtils.isNotEmpty(insPerNm)){
            view = new ModelAndView("inscare/stages/insPaymentInfomationDetail");
            view.addObject("insPerNm",insPerNm);
        }
        BaseLogUtils.info(logger,"获取无图图片地址","获取无图图片地址开始");
        String serverPath = PropertiesCacheUtils
                .getProperty(UploadConstant.UPLOAD_SERVER_PATH);// 服务地址
        String customerPah = PropertiesCacheUtils
                .getProperty(UploadConstant.UPLOAD_COSTOMER_PATH);
        String headPic = PropertiesCacheUtils
                .getProperty(fl.constant.facade.framework.constant.UploadConstant.DEFAULT_NO_PIC);
        BaseLogUtils.info(logger,"获取无图图片地址","获取无图图片地址结束");
        if (StringUtils.isNotEmpty(applicationId)){
            view = new ModelAndView("inscare/stages/insPaymentInfomationDetail");
            Map<String, Object> objMap = this.insApplicationStagingService.getInsPolilyFile(Long.valueOf(applicationId));
            view.addObject("fileCertNoPath", objMap.get("fileCertNo")); //身份证正面路径
            view.addObject("fileBackCertNoPath", objMap.get("fileBackCertNo")); //身份证反面路径
            view.addObject("fileVehiclePath", objMap.get("fileVehiclePath")); //行驶证正面路径
            view.addObject("fileVehicleBackPath", objMap.get("fileVehicleBackPath")); //行驶证反面路径
            view.addObject("fileApplyBussPath", objMap.get("fileApplyBussPath")); //营业执照路径
            view.addObject("filePolicyBPath", objMap.get("filePolicyB")); //商业险路径
            view.addObject("filePolicyJQPath", objMap.get("filePolicyJQ")); //交强险路径
            view.addObject("defImg", serverPath + customerPah + headPic);//无图片显示
            view.addObject("applicationId",applicationId);
        }
        BaseLogUtils.info(logger, "toInsApplicationStagingPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
        return view;
    }
    /**
     * 通过申请表id 或者 姓名来获取分期申请
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/getApplicationId.do" ,method = RequestMethod.GET)
    @ResponseBody
    public DataResultVO getApplicationId(HttpServletRequest request, HttpServletResponse response){
        //
        String cstNm = request.getParameter("cstNm");
        String applicationId = request.getParameter("applicationId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取对象成功!");
        try {
            InsApplicationVO insApplicationVO = this.insApplicationStagingService.getApplicationId
                    (Long.valueOf(applicationId), cstNm);
            result.setData(insApplicationVO);
            return result;
        } catch (BaseException be) {
            logger.info("获取分期申请列表异常，exMsg= " + be.getMessage());
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("获取分期申请列表异常，exMsg= " + be.getMessage());
        } catch (Exception ex) {
            logger.info("获取分期申请列表异常，exMsg= " + ex.getMessage());
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("获取分期申请列表异常，exMsg= " + ex.getMessage());
        }
        return result;


    }

    /**
     * 跳转报价方案页面
     *
     * @return
     */
    @RequestMapping(value = "/toPricingPage.do", method = {RequestMethod.GET})
    public ModelAndView toPricingPage(HttpServletRequest request) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "加载新增.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String applicationId = request.getParameter("applicationId");
        ModelAndView view = new ModelAndView("inscare/stages/pricingProposal");
        view.addObject("applicationId", applicationId);
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "加载新增.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 通过applicationid获取报价方案
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/getgetQuotation.do" ,method = RequestMethod.GET)
    @ResponseBody
    public DataResultVO getQuotation(HttpServletRequest request, HttpServletResponse response){
        //
        String prjId = request.getParameter("prjId");
        String applicationId = request.getParameter("applicationId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取对象成功!");
        try {
            QuotationVO vo = this.insApplicationStagingService.getApplicationId
                    (Long.valueOf(applicationId));
            result.setData(vo);
            return result;
        } catch (BaseException be) {
            logger.info("获取报价方案异常，exMsg= " + be.getMessage());
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("获取报价方案异常，exMsg= " + be.getMessage());
        } catch (Exception ex) {
            logger.info("获取报价方案异常，exMsg= " + ex.getMessage());
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("获取报价方案异常，exMsg= " + ex.getMessage());
        }
        return result;


    }


///////////////////////////////////////////////////////////////////
    /**
     * 跳转到分期申请
     */
    @RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "跳转到分期申请页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("inscare/stages/insApplicationAdd");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        String appid = request.getParameter("id");
        Map<String,Object> map = insApplicationStagingService.getApplicationR(Long.valueOf(prjPrdDtlId));
        if(map == null ){
        	view.addObject("prjPrdDtlId", prjPrdDtlId);
        	 Long applicationId = insApplicationStagingService.searchApplicationId();
        	// Long applicationId = this.insApplicationService.searchApplicationId();
             view.addObject("applyId", applicationId);  //新增是获取Id
             view.addObject("addOrUpdate","add");
        	return view;
        }else{
        	view.addObject("prjPrdDtlId", prjPrdDtlId);
        	InsApplicationDTO application = (InsApplicationDTO) map.get("application");
        	List<InsPolicyDetailDTO> list = (List<InsPolicyDetailDTO>) map.get("polic");
        	Map<Long,InsPolicyDetailDTO> r = new HashMap<Long, InsPolicyDetailDTO>();
        	for (InsPolicyDetailDTO insPolicyDetailDTO : list) {
        		insPolicyDetailDTO.setInsAmt(insPolicyDetailDTO.getInsAmt());
        		r.put(insPolicyDetailDTO.getInsTypeCd(),insPolicyDetailDTO);
			}
        	view.addObject("application", application);
        	view.addObject("policyDetailBs",r.get(1L));
        	view.addObject("policyDetailJq", r.get(2L));
        	view.addObject("bsAmt", MoneyConvert.fen2Yuan(r.get(1L).getInsAmt()));
        	view.addObject("jqAmt", MoneyConvert.fen2Yuan(r.get(2L).getInsAmt()));
        	view.addObject("applyId",application.getId());
        	view.addObject("addOrUpdate","update");
        	Map<String, Object> objMap = this.insApplicationStagingService.getInsPolilyFile(application.getId());
	        view.addObject("fileCertNoPath", objMap.get("fileCertNo")); //身份证正面路径
	        view.addObject("fileBackCertNoPath", objMap.get("fileBackCertNo")); //身份证反面路径
	        view.addObject("fileVehiclePath", objMap.get("fileVehiclePath")); //行驶证正面路径
	        view.addObject("fileVehicleBackPath", objMap.get("fileVehicleBackPath")); //行驶证反面路径
	        view.addObject("fileApplyBussPath", objMap.get("fileApplyBussPath")); //营业执照路径
	        view.addObject("filePolicyBPathList", objMap.get("filePolicyB")); //商业险路径
	        view.addObject("filePolicyJQPathList", objMap.get("filePolicyJQ")); //交强险路径
        }
       
        BaseLogUtils.info(logger, "toAddPage", "跳转到分期申请页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "跳转到分期申请页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    
    /**
     * 获取省级区域数据
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getProvinceRegion.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object getProvinceRegion(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);

        try {
            List<KeyValueVO> provinceKVList = new ArrayList<KeyValueVO>();
            //查询所有省级区域
//            String sysRegionsysCd = PropertiesCacheUtils.getProperty(SystemConstant.FL_SERVICE_CD);
            List<SysRegionDTO> stdRegionList = this.sysRegionApiService.searchProvinceList("11000");
            if (CollectionUtils.isNotEmpty(stdRegionList)) {
                for (SysRegionDTO sysRegionDTO : stdRegionList) {
                    KeyValueVO valueVO = new KeyValueVO();
                    valueVO.setKey(String.valueOf(sysRegionDTO.getRgnCd()));
                    valueVO.setValue(sysRegionDTO.getRgnNm());
                    provinceKVList.add(valueVO);
                }
            }
            if (CollectionUtils.isEmpty(provinceKVList)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在！");
                BaseLogUtils.info(logger, "getProvinceRegion", "获取数据,数据不存在.", CurrentThreadContext.getCurrentUserName());
            }
            JSONArray provinceKVListJson = JSONArray.fromObject(provinceKVList.toArray());
            result.setData(provinceKVListJson);
            BaseLogUtils.info(logger, "getProvinceRegion", "获取数据.", CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getProvinceRegion", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getProvinceRegion", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }
    
    /**
     * 根据区域代码获取子级区域数据
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getRegionByRgnCd.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object getRegionByRgnCd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String rgnCd = request.getParameter("rgnCd");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isBlank(rgnCd)) {
        	 result.setSuccess(BaseConstant.IS_YESNO_NO);
             result.setInfo("获取区域代码错误");
             return result;
        }
        try {
            List<KeyValueVO> rgnKvList = new ArrayList<KeyValueVO>();
            //根据区域代码获取子区域
           // String sysCd = PropertiesCacheUtils.getProperty(SystemConstant.FL_SERVICE_CD);
            SysRegionQueryCondition condition = new SysRegionQueryCondition();
            condition.setRgnCd(rgnCd);
            condition.setSysCd("11000");
            List<SysRegionDTO> searchRegineByRgnPid = this.sysRegionApiService.searchRegionList(condition);
            SysRegionDTO sysRegionDTO2 = searchRegineByRgnPid.get(0);
            List<SysRegionDTO> searchRegineByRgnPid2 = this.sysRegionApiService.searchRegineByRgnPid(sysRegionDTO2.getId(), "11000");
            if (CollectionUtils.isNotEmpty(searchRegineByRgnPid2)) {
                for (SysRegionDTO sysRegionDTO : searchRegineByRgnPid2) {
                    KeyValueVO valueVO = new KeyValueVO();
                    valueVO.setKey(String.valueOf(sysRegionDTO.getRgnCd()));
                    valueVO.setValue(sysRegionDTO.getRgnNm());
                    rgnKvList.add(valueVO);
                }
            }

            if (CollectionUtils.isNotEmpty(rgnKvList)) {
                JSONArray rgnKvListJson = JSONArray.fromObject(rgnKvList.toArray());
                result.setData(rgnKvListJson);
                BaseLogUtils.info(logger, "getRegionByRgnCd", "获取数据.", CurrentThreadContext.getCurrentUserName());
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getRegionByRgnCd", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getRegionByRgnCd", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }
    
    /**
     * 获取保险公司数据
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getCompCdRegion.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object getinsCompCdRegion(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);

        try {
            List<KeyValueVO> provinceKVList = new ArrayList<KeyValueVO>();
            provinceKVList = insApplicationStagingService.selectSubInsCompList(1,null);
            if (cn.cmm.base.framework.utils.CollectionUtils.isEmpty(provinceKVList)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在！");
                BaseLogUtils.info(logger, "getinsCompCdRegion", "获取数据,数据不存在.", CurrentThreadContext.getCurrentUserName());
            }
            net.sf.json.JSONArray provinceKVListJson = net.sf.json.JSONArray.fromObject(provinceKVList.toArray());
            result.setData(provinceKVListJson);
            BaseLogUtils.info(logger, "getinsCompCdRegion", "获取数据.", CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getinsCompCdRegion", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getinsCompCdRegion", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }
    
    /**
     * 根据保险公司ID 获取保险子公司数据
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getBusCompByIns.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object getBusCompByIns(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String insCompId = request.getParameter("insCompId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isBlank(insCompId)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("保险公司ID为空");
            return result;
        }
        try {
            List<KeyValueVO> rgnKvList = new ArrayList<KeyValueVO>();
            InsCompInfoQC qc = new InsCompInfoQC();
            qc.setCompPid(Long.valueOf(insCompId));
            rgnKvList = insApplicationStagingService.selectSubInsCompList(2,qc);
            if (CollectionUtils.isNotEmpty(rgnKvList)) {
                JSONArray rgnKvListJson = JSONArray.fromObject(rgnKvList.toArray());
                result.setData(rgnKvListJson);
                BaseLogUtils.info(logger, "getBusCompByIns", "获取数据.", CurrentThreadContext.getCurrentUserName());
            }
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getBusCompByIns", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getBusCompByIns", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }
    
    @RequestMapping(value = "/addApplication.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addApplication(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "add", "新增对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
       
        String prjPrdDtlId = request.getParameter("prjPrdDtlId"); //
        //=======================被保人信息=====================
        String certTypCd = request.getParameter("certTypCd"); //被保险人类型
        String insPerNm = request.getParameter("insPerNm");//被保险人姓名
        String idCard = request.getParameter("idCard");  //证件号
        String mp = request.getParameter("mp");  //被保险人手机号
        
        //=================保险公司及险种信息====================
        String insCompCd = request.getParameter("insCompCd");  //保险公司
        String insCompNm = request.getParameter("insCompNm");  //保险公司
        String rgnPrCd = request.getParameter("rgnProvCd");  //保险公司所属省份
        String rgnPrNm = request.getParameter("rgnPrNm");  //保险公司所属省份
        String rgnCyCd = request.getParameter("rgnCityCd");  //保险公司所属城市
        String rgnCyNm = request.getParameter("rgnCyNm");  //保险公司所属城市
        String insCompSubCd = request.getParameter("insCompSubCd");  //保险支公司
        String insCompSubNm = request.getParameter("insCompSubNm");  //保险支公司

        String plcBgTmBs = request.getParameter("plcBgTmBs");  //商业险起保期限开始时间
        String plcEndTmBs = request.getParameter("plcEndTmBs");  //商业险起保期限结束时间
        String insPolicyBusAmt = request.getParameter("insPolicyBusAmt");  //商业险保费
        Long policyBusAmt ;
        if(StringUtils.isEmpty(insPolicyBusAmt)){
        	policyBusAmt = 0L;
        }else{
        	policyBusAmt = Long.valueOf(DecimalUtils.convertYuanToFen(Double.valueOf(insPolicyBusAmt)));
        }
        
        String plcBgTmJq = request.getParameter("plcBgTmJq");  //交强险起保期限开始时间
        String plcEndTmJq = request.getParameter("plcEndTmJq");  //交强险起保期限开始时间
        String insPolicyJqAmt = request.getParameter("insPolicyJqAmt");  //交强险险保费
        Long PolicyJqAmt;
        if(StringUtils.isEmpty(insPolicyJqAmt)){
        	PolicyJqAmt=0L;
        }else{
        	PolicyJqAmt = Long.valueOf(DecimalUtils.convertYuanToFen(Double.valueOf(insPolicyJqAmt)));
        }
        AddAplicationVo addvo = new AddAplicationVo();
        addvo.setPrjPrdDtlId(prjPrdDtlId);
        addvo.setCertTypCd(certTypCd);
        addvo.setInsPerNm(insPerNm);
        addvo.setIdCard(idCard);
        addvo.setMp(mp);
        addvo.setInsCompCd(insCompCd);
        addvo.setInsCompNm(insCompNm);
        addvo.setRgnCyCd(rgnCyCd);
        addvo.setRgnCyNm(rgnCyNm);
        addvo.setRgnPrCd(rgnPrCd);
        addvo.setRgnPrNm(rgnPrNm);
        addvo.setInsCompSubCd(insCompSubCd);
        addvo.setInsCompSubNm(insCompSubNm);
        addvo.setPlcBgTmBs(plcBgTmBs);
        addvo.setPlcEndTmBs(plcEndTmBs);
        addvo.setPlcBgTmJq(plcBgTmJq);
        addvo.setPlcEndTmJq(plcEndTmJq);
        addvo.setInsPolicyBusAmt(policyBusAmt);
        String applyId = request.getParameter("applyId");
        addvo.setInsPolicyJqAmt(PolicyJqAmt);
        addvo.setId(applyId);
        String addOrUpdate = request.getParameter("addOrUpdate");
        if(StringUtils.isEmpty(applyId)){
        	 result.setSuccess(BaseConstant.IS_YESNO_NO);
             result.setInfo("申请单ID为空！");
             BaseLogUtils.error(logger, "addApplication", "申请单ID为空！", CurrentThreadContext.getCurrentUserName());
             return result;
        }
       
        try {
        	//产品详情Id查询 车辆信息,投保人,投保人id,支付表编号,支付表号,项目id,项目产品id
        	 String success;
        	 if("add".equals(addOrUpdate)){
        		 InsApplicationDTO insAppList = insApplicationStagingService.searchAppIdById(Long.valueOf(applyId));
        	        if (null != insAppList) {
        	            result.setSuccess(BaseConstant.IS_YESNO_NO);
        	            result.setInfo("不能重复添加数据！");
        	            BaseLogUtils.error(logger, "addApplication", "不能重复添加数据！", CurrentThreadContext.getCurrentUserName());
        	            return result;
        	        }
        		 //新增
        		  success= insApplicationStagingService.getInsApplication(addvo);
        		  result.setInfo("新增成功!");
             }else{
            	 //修改
                 InsApplicationDTO dto = insApplicationStagingService.searchAppIdById(Long.valueOf(applyId));

                 if("1".equals(dto.getOrderStatus() )|| StringUtils.isEmpty(dto.getOrderStatus())){
                     success = insApplicationStagingService.modifyApplication(addvo,Long.valueOf(applyId));
                     result.setInfo("修改成功!");
                 }else{
                     result.setInfo("该数据不能修改");
                     return result;
                 }
             }
        	if ("0".equals(success)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("保存失败!");
                BaseLogUtils.info(logger, "modify", "保存失败 DATA:" + JSONObject.toJSONString(addvo), CurrentThreadContext.getCurrentUserName());
                
        	}else if("1".equals(success)){

        	}else{
            	 result.setSuccess(BaseConstant.IS_YESNO_NO);
                 result.setInfo("生成支付表失败:"+success);
                 BaseLogUtils.info(logger, "modify", "保存失败 DATA:" + JSONObject.toJSONString(addvo), CurrentThreadContext.getCurrentUserName());
            }
        	
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "add", "新增对象失败,name[" + JSONObject.toJSONString(addvo) + "].", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "add", "新增对象失败,name[" + JSONObject.toJSONString(addvo) + "].", CurrentThreadContext.getCurrentUserName(), ex);
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "add", "新增对象.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());

        return result;
    }
    
    
    /**
     * 跳转到立项分期申请tab
     */
    @RequestMapping(value = "/toInsuranceTabPage.do", method = { RequestMethod.GET})
    public ModelAndView toInsuranceTabPage(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toInsuranceTabPage", "跳转到分期申请页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("inscare/stages/InsuranceTabPage");
        String prjId = request.getParameter("prjId");
		String detailFlag = request.getParameter("detailFlag");
		view.addObject("detailFlag", detailFlag);
        view.addObject("prjId", prjId);
        BaseLogUtils.info(logger, "toInsuranceTabPage", "跳转到分期申请页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toInsuranceTabPage", "跳转到分期申请页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    
    /**
     * 跳转到选择项目产品
     */
    @RequestMapping(value = "/toSelectPrjPrd.do", method = { RequestMethod.GET})
    public ModelAndView toSelectPrjPrd(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toSelectPrjPrd", "跳转到选择项目产品页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("inscare/stages/prjPrdDtlListPage");
        String prjId = request.getParameter("prjId");
        view.addObject("prjId", prjId);
        BaseLogUtils.info(logger, "toSelectPrjPrd", "跳转到选择项目产品页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toSelectPrjPrd", "跳转到选择项目产品页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    
    @RequestMapping(value = "/initData.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object initData(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功!");

        BaseLogUtils.info(logger, "initData", "跳转到选择项目产品页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String prjId = request.getParameter("prjId");
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		if(StringUtils.isEmpty(prjId)){
			 result.setSuccess(BaseConstant.IS_YESNO_NO);
             result.setInfo("项目ID不能为空");
			 return result;
		}
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		
		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		Pager  list = new Pager();
		 try {
			 list = insApplicationStagingService.getInsApplication( page, Long.valueOf(prjId));
		 }catch(BaseException ex){
			 result.setSuccess(BaseConstant.IS_YESNO_NO);
             result.setInfo("保存失败!");
			 return result;
		 }
		List<InsApplicationDTO> r = (List<InsApplicationDTO>) list.getResultList();
		ListPageVO<InsApplicationDTO> listPage = new ListPageVO<InsApplicationDTO>(r, page.getTotalCount());
        BaseLogUtils.info(logger, "initData", "跳转到选择项目产品页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toSelectPrjPrd", "跳转到选择项目产品页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return listPage;
    }
    
    
    /**
     * 跳转到分期申请
     */
    @RequestMapping(value = "/toTabAddPage.do", method = { RequestMethod.GET})
    public ModelAndView toTabAddPage(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toTabAddPage", "跳转到分期申请页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("inscare/stages/insApplicationTabAdd");
        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        Map<String,Object> map = insApplicationStagingService.getApplicationR(Long.valueOf(prjPrdDtlId));
        if(map == null ){
        	view.addObject("prjPrdDtlId", prjPrdDtlId);
        	Long applicationId = insApplicationStagingService.searchApplicationId();
        	view.addObject("applyId", applicationId);  //新增是获取Id
            view.addObject("addOrUpdate","add");
        	return view;
        }else{
        	view.addObject("prjPrdDtlId", prjPrdDtlId);
        	InsApplicationDTO application = (InsApplicationDTO) map.get("application");
        	List<InsPolicyDetailDTO> list = (List<InsPolicyDetailDTO>) map.get("polic");
        	Map<Long,InsPolicyDetailDTO> r = new HashMap<Long, InsPolicyDetailDTO>();
        	for (InsPolicyDetailDTO insPolicyDetailDTO : list) {
        		insPolicyDetailDTO.setInsAmt(insPolicyDetailDTO.getInsAmt());
        		r.put(insPolicyDetailDTO.getInsTypeCd(),insPolicyDetailDTO);
			}
        	view.addObject("application", application);
        	view.addObject("policyDetailBs", r.get(1L));
        	view.addObject("policyDetailJq", r.get(2L));
        	view.addObject("bsAmt", MoneyConvert.fen2Yuan(r.get(1L).getInsAmt()));
        	view.addObject("jqAmt", MoneyConvert.fen2Yuan(r.get(2L).getInsAmt()));
        	view.addObject("applyId",application.getId());
        	view.addObject("addOrUpdate","update");
        	Map<String, Object> objMap = this.insApplicationStagingService.getInsPolilyFile(application.getId());
	        view.addObject("fileCertNoPath", objMap.get("fileCertNo")); //身份证正面路径
	        view.addObject("fileBackCertNoPath", objMap.get("fileBackCertNo")); //身份证反面路径
	        view.addObject("fileVehiclePath", objMap.get("fileVehiclePath")); //行驶证正面路径
	        view.addObject("fileVehicleBackPath", objMap.get("fileVehicleBackPath")); //行驶证反面路径
	        view.addObject("fileApplyBussPath", objMap.get("fileApplyBussPath")); //营业执照路径
	        view.addObject("filePolicyBPathList", objMap.get("filePolicyB")); //商业险路径
	        view.addObject("filePolicyJQPathList", objMap.get("filePolicyJQ")); //交强险路径
        	
        }
       
        BaseLogUtils.info(logger, "toTabAddPage", "跳转到分期申请页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toTabAddPage", "跳转到分期申请页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    
    /**
     * 跳转到分期申请
     */
    @RequestMapping(value = "/toBjPage.do", method = { RequestMethod.GET})
    public ModelAndView toBjPage(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toBjPage", "跳转到分期申请页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("inscare/stages/insBjPage");
        
       
        BaseLogUtils.info(logger, "toAddPage", "跳转到分期申请页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toAddPage", "跳转到分期申请页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    @RequestMapping(value = "/deleteByApplyId.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object deleteByApplyId(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");

        String applyId = request.getParameter("applyId");
        if(StringUtils.isEmpty(applyId)){
	    	  result.setSuccess(BaseConstant.IS_YESNO_NO);
	          result.setInfo("删除失败:applyId不能为空");
	          return result;
        }
        BaseLogUtils.info(logger, "deleteByApplyId", "删除.请求参数：" + applyId, CurrentThreadContext.getCurrentUserName());
        try {
        	boolean b =insApplicationStagingService.deleteApplication(Long.valueOf(applyId));
        	if(b){
        		 return result;
        	}else{
        		result.setSuccess(BaseConstant.IS_YESNO_NO);
        		return result;
        	}
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "deleteByApplyId", "删除失败,", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "deleteByApplyId", "删除失败,", CurrentThreadContext.getCurrentUserName(), ex);
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "deleteByApplyId", "删除.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return result;
    }
    
    
    /**
     * 校验项目
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/checkProject.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object checkProject(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");

        String prjId = request.getParameter("prjId");
        if(StringUtils.isEmpty(prjId)){
	    	  result.setSuccess(BaseConstant.IS_YESNO_NO);
	          result.setInfo("prjId不能为空");
	          return result;
        }
        BaseLogUtils.info(logger, "checkProject", "请求参数：" + prjId, CurrentThreadContext.getCurrentUserName());
        try {
        	Long gh = insApplicationStagingService.checkProjectInformation(Long.valueOf(prjId),1L);
        	if(gh == 1){
        	  result.setSuccess(BaseConstant.IS_YESNO_NO);
  	          result.setInfo("所选业务不支持保险分期");
  	          return result;
        	}
        	Long prd = insApplicationStagingService.checkProjectInformation(Long.valueOf(prjId),2L);
        	if(prd == 2){
        	  result.setSuccess(BaseConstant.IS_YESNO_NO);
  	          result.setInfo("请先维护项目产品信息");
  	          return result;
        	}
        	Long bj = insApplicationStagingService.checkProjectInformation(Long.valueOf(prjId),3L);
        	if(bj == 3){
        	  result.setSuccess(BaseConstant.IS_YESNO_NO);
  	          result.setInfo("请先选择报价方案信息");
  	          return result;
        	}
        	
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "checkProject", "删除失败,", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "checkProject", "删除失败,", CurrentThreadContext.getCurrentUserName(), ex);
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "checkProject", "删除.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return result;
    }
    
    /**
     * 校验是否做过分期
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/checkData.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object checkData(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");

        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        if(StringUtils.isEmpty(prjPrdDtlId)){
	    	  result.setSuccess(BaseConstant.IS_YESNO_NO);
	          result.setInfo("项目产品明细ID不能为空");
	          return result;
        }
        BaseLogUtils.info(logger, "checkData", "请求参数：" + prjPrdDtlId, CurrentThreadContext.getCurrentUserName());
        try {
        	boolean b = insApplicationStagingService.checkData(Long.valueOf(prjPrdDtlId));
        	if(b){
        	  result.setSuccess(BaseConstant.IS_YESNO_NO);
  	          result.setInfo("您勾选的产品已存在保险分期申请，请不要重复申请");
  	          return result;
        	}
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "checkData", "操作失败,", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "checkData", "操作失败,", CurrentThreadContext.getCurrentUserName(), ex);
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "checkData", "操作失败.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return result;
    }
    
    /**
     * 校验是否有合格证信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/checkVehon.do", method = { RequestMethod.GET})
    @ResponseBody
    public Object checkVehon(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");

        String prjPrdDtlId = request.getParameter("prjPrdDtlId");
        if(StringUtils.isEmpty(prjPrdDtlId)){
	    	  result.setSuccess(BaseConstant.IS_YESNO_NO);
	          result.setInfo("项目产品明细ID不能为空");
	          return result;
        }
        BaseLogUtils.info(logger, "checkVehon", "请求参数：" + prjPrdDtlId, CurrentThreadContext.getCurrentUserName());
        try {
        	boolean b = insApplicationStagingService.checkVehon(Long.valueOf(prjPrdDtlId));
        	if(!b){
        	  result.setSuccess(BaseConstant.IS_YESNO_NO);
  	          result.setInfo("合格证编号为空不能做分期申请");
  	          return result;
        	}
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "checkVehon", "操作失败,", CurrentThreadContext.getCurrentUserName(), ex);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("系统错误,请联系管理员!");
            BaseLogUtils.error(logger, "checkData", "操作失败,", CurrentThreadContext.getCurrentUserName(), ex);
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "checkData", "操作失败.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return result;
    }
    
    
    /**
     * 跳转修改申请单
     */
    @RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response){
	    Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toModifyPage", "跳转修改申请单页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
//        ModelAndView view = new ModelAndView("inscare/stages/insApplicationAdd");
        ModelAndView view = new ModelAndView("inscare/stages/insApplicationTabAdd");
        String appid = request.getParameter("id");
       
        Map<String,Object> map = insApplicationStagingService.getApplication(Long.valueOf(appid));
        
    	InsApplicationDTO application = (InsApplicationDTO) map.get("application");
    	List<InsPolicyDetailDTO> list = (List<InsPolicyDetailDTO>) map.get("polic");
    	Map<Long,InsPolicyDetailDTO> r = new HashMap<Long, InsPolicyDetailDTO>();
    	for (InsPolicyDetailDTO insPolicyDetailDTO : list) {
    		insPolicyDetailDTO.setInsAmt(insPolicyDetailDTO.getInsAmt());
    		r.put(insPolicyDetailDTO.getInsTypeCd(),insPolicyDetailDTO);
		}
    	view.addObject("prjPrdDtlId", map.get("prjPrdDtlId"));
    	view.addObject("application", application);
    	view.addObject("policyDetailBs", r.get(1L));
    	view.addObject("policyDetailJq", r.get(2L));
    	view.addObject("bsAmt", MoneyConvert.fen2Yuan(r.get(1L).getInsAmt()));
    	view.addObject("jqAmt", MoneyConvert.fen2Yuan(r.get(2L).getInsAmt()));
    	view.addObject("applyId",application.getId());
    	view.addObject("addOrUpdate","update");
    	Map<String, Object> objMap = this.insApplicationStagingService.getInsPolilyFile(application.getId());
        view.addObject("fileCertNoPath", objMap.get("fileCertNo")); //身份证正面路径
        view.addObject("fileBackCertNoPath", objMap.get("fileBackCertNo")); //身份证反面路径
        view.addObject("fileVehiclePath", objMap.get("fileVehiclePath")); //行驶证正面路径
        view.addObject("fileVehicleBackPath", objMap.get("fileVehicleBackPath")); //行驶证反面路径
        view.addObject("fileApplyBussPath", objMap.get("fileApplyBussPath")); //营业执照路径
        view.addObject("filePolicyBPathList", objMap.get("filePolicyB")); //商业险路径
        view.addObject("filePolicyJQPathList", objMap.get("filePolicyJQ")); //交强险路径
       
        BaseLogUtils.info(logger, "toModifyPage", "跳转修改申请单页面.", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toModifyPage", "跳转修改申请单页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    
    
    @RequestMapping(value = "/getPrjPplR.do", method = { RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    public Object getPrjPplR(HttpServletRequest request, HttpServletResponse response) {
    	 Long startTm = System.currentTimeMillis();
         DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功!");
         BaseLogUtils.info(logger, "getPrjPplR", ".请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

    	String applyId = request.getParameter("applyId");//项目id
        if(StringUtils.isEmpty(applyId)){
        	  result.setSuccess(BaseConstant.IS_YESNO_NO);
	          result.setInfo("applyId不能为空");
	          return result;
        }
        InsPrjApplRDTO dto = insApplicationStagingService.getPrjPplR(Long.valueOf(applyId));
        result.setData(dto);
        BaseLogUtils.info(logger, "getPrjPplR", "", CurrentThreadContext.getCurrentUserName());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toModifyPage", "跳转修改申请单页面.耗时：" + (endTm - startTm), CurrentThreadContext.getCurrentUserName());
        return result;
    }

    @RequestMapping(value = "/getCityCd.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object getCityCd(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);

        try {


            String compId = request.getParameter("compId");
            Map map = insApplicationStagingService.getCompCity(Long.valueOf(compId));
            if (map.size()<1) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("数据不存在！");
                BaseLogUtils.info(logger, "getinsCompCdRegion", "获取数据,数据不存在.", CurrentThreadContext.getCurrentUserName());
            }
            //  net.sf.json.JSONArray provinceKVListJson = net.sf.json.JSONArray.fromObject(provinceKVList.toArray());
            result.setData(map);
            BaseLogUtils.info(logger, "getinsCompCdRegion", "获取数据.", CurrentThreadContext.getCurrentUserName());
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getinsCompCdRegion", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getinsCompCdRegion", "获取失败." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }
}
